home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
tools
/
zmc3v078
/
zmc3v078.lzh
/
SRCSV078.LZH
/
MAKEZMD.C
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-15
|
4KB
|
153 lines
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "makezmd1.h"
#include "makezmd2.h"
#include "v3macro.h"
#include "etc.h"
#define MAXTRK (80 + 1)
#define COMNTRKSIZE 8192
#include "structs.h"
#include "structs2.h"
TRKCHINF *makeZmd(UBYTE *zmsbuf, char *infile,COMMONINF *cominf, DWORD *totalstep);
void initTrkInf0(TRKCHINF *trkdata, int t);
DWORD line = 1, linebak = 1;
char *linebuf = NULL;
char *infile;
LINEDATA *ld, *ldorg;
LINEFILEDATA *lfd, *lfdorg;
TRKCHINF *makeZmd(UBYTE *zmsbuf, char *infile_,COMMONINF *cominf, DWORD *totalstep)
{
int i, trks;
TRKCHINF *trkdata;
UBYTE *zms2;
ld = ldorg = (LINEDATA*)emalloc(sizeof(LINEDATA) * 1, "LINEDATA");
lfd = lfdorg = (LINEFILEDATA*)emalloc(sizeof(LINEFILEDATA) * 1, "LINEFILEDATA");
lfd->next = NULL;
lfd->filename = (char*)emalloc(sizeof(char*) * (strlen(infile_) + 1), "infile_in_makezmd");
strcpy(lfd->filename,infile_);
ld->next = NULL;
ld->filename = lfd->filename;
ld->line = 1;
infile = (char*)emalloc(sizeof(char*) * (strlen(infile_) + 1), "infile_in_makezmd");
strcpy(infile,infile_);
cominf->maxtrk = MAXTRK;
zmsbuf = expandV3macro(zmsbuf, ld, lfd);
#ifdef AA
ld = ldorg;
while (ld->next) {
fprintf(stderr, "[%d %s]",ld->line, ld->filename);
ld = ld->next;
}
ld = ldorg;
#endif
trkdata = (TRKCHINF*)emalloc(sizeof(TRKCHINF) * MAXTRK,"trkdata_in_makezmd");
linebuf = zmsbuf;
cominf->trkassign[0] = -1;
cominf->renpmode = 1;
cominf->trackmode = 0;
for (i = 0; i < MAXTRK; i++) {
trkdata[i].ch = trkdata[i].ch_ = -1;
cominf->backtrk[i] = cominf->fromtrk[i] = -1;
}
trkdata[0].zmdbuf = (UBYTE*)emalloc(sizeof(UBYTE) * COMNTRKSIZE,"trkdata[0].zmdbuf");
trkdata[0].bufsize = COMNTRKSIZE;
trkdata[0].zmd = trkdata[0].zmdbuf;
trkdata[0].nowsize = 0;
cominf->div = cominf->div2 = 192;
cominf->tempo = 120;
cominf->basech = 0;
cominf->debug = 0;
cominf->l1tie = 0;
cominf->qmode = 3;
cominf->gtreso = 8;
cominf->cmnt = 0;
cominf->meter = 0;
cominf->key = 0;
cominf->majorflag = 0;
cominf->currentmidiin = 0;
cominf->currentmidiout = 0;
cominf->backinuse = 0;
linebuf = zmsbuf;
makeZmdCommon(trkdata,zmsbuf,&zms2,cominf,0);
#ifdef AAA
{
FILE *fp;
fp = fopen("test.zmd","wb");
fwrite(trkdata[0].zmdbuf,sizeof(UBYTE),trkdata[0].nowsize,fp);
fclose(fp);
exit(1);
}
#endif
/* moved to makezmd1.c */
#ifdef A
for (i = 0, trks = 0; cominf->trkassign[i] >= 0; i++, trks++) {
const int t = cominf->trkassign[i];
initTrkInf0(trkdata, t);
}
for (i = trks; i < cominf->maxtrk; i++) {
/* trkdata[i].zmdbuf = NULL; */
}
#endif
/* makeZmdMain(trkdata,zms,&zms2,infile_,cominf,trkinf); */
makeZmdMain(trkdata,zms2,&zms2,cominf, totalstep);
while (ldorg->next) {
ld = ldorg;
ldorg = ldorg->next;
efree(ld, "ld");
}
efree(ldorg, "ldorg");
while (lfdorg->next) {
lfd = lfdorg;
lfdorg = lfdorg->next;
efree(lfd->filename,"lfd->filename");
efree(lfd, "lfd");
}
efree(lfdorg, "lfdorg");
/* trkdata[0].nowsize = trkdata[0].zmd - trkdata[0].zmdbuf; */
efree(infile,"infile_in_makezmd");
efree(zmsbuf,"zmsbuf_in_makezmd"); /* free the memory for macro expanded zms) */
return trkdata;
}
void initTrkInf0(TRKCHINF *trkdata, int t)
{
char s[32];
sprintf(s,"trkdata[%d].zmdbuf",t);
trkdata[t].zmdbuf = (UBYTE*)emalloc(sizeof(UBYTE) * COMNTRKSIZE,s);
trkdata[t].bufsize = COMNTRKSIZE;
trkdata[t].zmd = trkdata[t].zmdbuf;
trkdata[t].nowsize = 0;
trkdata[t].backinuse = -1;
trkdata[t].mute = 1;
}